package parser;

public class PInsert {
//attribution
	public String tableName;
	public int attributionNum;
	public String []attributions;
	public String []values;
//method
	PInsert(String cmd){
		String []sAry;
		String []ss;
		sAry = cmd.split("\\s+INTO\\s+");
		sAry = sAry[1].split("\\s+VALUES\\s*");
		//sAry[0](tablename(...)),sAry[1](values(...))
		ss = sAry[0].split("\\s*\\(\\s*");
		tableName = ss[0];
		if(ss[1].endsWith(")")){
			ss[1] = ss[1].substring(0,ss[1].length()-1);
		}
		ss = ss[1].split("\\s*\\,\\s*");
		attributionNum = ss.length;
		attributions = new String[attributionNum];
		values = new String[attributionNum];
		for(int i=0; i<attributionNum; i++)
			attributions[i] = ss[i];
		//sAry[1]
		ss = sAry[1].split("\\s*\\(\\s*");
		if(ss[1].endsWith(")")){
			ss[1] = ss[1].substring(0,ss[1].length()-1);
		}
		ss = ss[1].split("\\s*\\,\\s*");
		for(int i=0; i<attributionNum; i++)
		{
			values[i] = ss[i];
		}
		//System.out.print("");
	}
}
